package com.yicong.ants.scenic.banner

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.toolbox.util.banner.IBannerItem
import com.yicong.ants.R

class BannerAdapter(val data: List<IBannerItem>, val layoutResId: Int) :
    com.youth.banner.adapter.BannerAdapter<IBannerItem, RecyclerView.ViewHolder>(data) {

    override fun onCreateHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return object : RecyclerView.ViewHolder(
            LayoutInflater.from(parent.context).inflate(layoutResId, parent, false)
        ) {}
    }

    override fun onBindView(
        holder: RecyclerView.ViewHolder,
        data: IBannerItem,
        position: Int,
        size: Int
    ) {
        Glide.with(holder.itemView).load(data.getImgUrl())
            .into(holder.itemView.findViewById(R.id.bannerIV))
    }
}